/*
*  Copyright 2019-2025 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.account.rest;

import me.zhengjie.annotation.Log;
import lombok.RequiredArgsConstructor;

import java.util.HashMap;
import java.util.List;

import me.zhengjie.modules.account.domain.AccountAa03;
import me.zhengjie.modules.account.domain.dto.AccountAa03QueryCriteria;
import me.zhengjie.modules.account.service.AccountAa03Service;
import me.zhengjie.modules.account.service.AccountService;
import me.zhengjie.modules.transfer.service.TransferOutService;
import me.zhengjie.tool.MyMap;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.zhengjie.utils.PageResult;

/**
* @author lzw
* @date 2025-04-23
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "api")
@RequestMapping("/api/accountAa03")
public class AccountAa03Controller {

    private final AccountAa03Service accountAa03Service;
    private final AccountService accountService;
    private final TransferOutService transferOutService;

    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('accountAa03:list')")
    public void exportAccountAa03(HttpServletResponse response, AccountAa03QueryCriteria criteria) throws IOException {
        accountAa03Service.download(accountAa03Service.queryAll(criteria), response);

    }

    @GetMapping
    @ApiOperation("查询利率")
    @PreAuthorize("@el.check('accountAa03:list')")
    public ResponseEntity<PageResult<AccountAa03>> queryAccountAa03(AccountAa03QueryCriteria criteria){
        Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
        return new ResponseEntity<>(accountAa03Service.queryAll(criteria,page),HttpStatus.OK);
    }

    @PostMapping
    @Log("新增利率")
    @ApiOperation("新增利率")
    @PreAuthorize("@el.check('accountAa03:add')")
    public ResponseEntity<Object> createAccountAa03( @RequestBody AccountAa03 resources) throws IOException {

        accountAa03Service.create(resources);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }

    @PutMapping
    @Log("维护利率")
    @ApiOperation("维护利率")
    @PreAuthorize("@el.check('accountAa03:edit')")
    public ResponseEntity<Object> updateAccountAa03( @RequestBody AccountAa03 resources) throws IOException {
        accountAa03Service.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @DeleteMapping
    @Log("删除利率")
    @ApiOperation("删除利率")
    @PreAuthorize("@el.check('accountAa03:del')")
    public ResponseEntity<Object> deleteAccountAa03(@ApiParam(value = "传ID数组[]") @RequestBody List<String> ids) throws IOException {
        accountAa03Service.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
